/**
 * @file      ac_tlm_bit_count.cpp
 * @author    Grupo 04
 * 
 * @brief     Implements a ac_tlm_bit_count.
 */

//////////////////////////////////////////////////////////////////////////////
// Standard includes
// SystemC includes
// ArchC includes

#include "ac_tlm_bit_count.h"

//////////////////////////////////////////////////////////////////////////////

/// Namespace to isolate memory from ArchC
using user::ac_tlm_bit_count;

/// Constructor
ac_tlm_bit_count::ac_tlm_bit_count( sc_module_name module_name) :
  sc_module( module_name ),
  target_export("bit_count_port")
{
    /// Binds target_export to the counter
    target_export( *this );
    valor=0;
}


/** Internal Write
  * Note: Always write 32 bits
  * @param a is the address to write
  * @param d id the data being write
  * @returns A TLM response packet with SUCCESS
*/
ac_tlm_rsp_status ac_tlm_bit_count::writem(const uint32_t &d )
{
  valor = bit_count(d);
  return SUCCESS;
}

/** Internal Read
  * Note: Always read 32 bits
  * @param a is the address to read
  * @param d id the data that will be read
  * @returns A TLM response packet with SUCCESS and a modified d
*/
ac_tlm_rsp_status ac_tlm_bit_count::readm(uint32_t &d)
{
  d = valor;
  return SUCCESS;
}


